package chapter9;

interface E {
    void g();

    interface G {
        void f();
    }

    public interface H {
        void f();
    }
}

/**
 * @author lzy
 * @version v1.0
 * Create DateTime: 2019/3/9 10:10
 */
class A {
    private D dRef;

    public D getD() {
        return new DImpl2();
    }

    public void receiveD(D dRef) {
        this.dRef = dRef;
        this.dRef.f();
    }

    interface B {
        void f();
    }

    public interface C {
        void f();
    }

    private interface D {
        void f();
    }

    public class BImp implements B {
        @Override
        public void f() {

        }
    }

    private class Bimp2 implements B {

        @Override
        public void f() {

        }
    }

    class CImpl implements C {

        @Override
        public void f() {

        }
    }

    private class CImpl2 implements C {

        @Override
        public void f() {

        }
    }

    private class DImpl implements D {

        @Override
        public void f() {

        }
    }

    public class DImpl2 implements D {

        @Override
        public void f() {

        }
    }
}

public class NestingInterfaces {
    public static void main(String[] args) {
        A a = new A();
//        A.D dImpl2 = a.getD();
        a.receiveD(a.getD());
        A.DImpl2 impl2 = a.new DImpl2();
        impl2.f();
    }

    public class BImpl implements A.B {

        @Override
        public void f() {

        }
    }

    class CImpl implements A.C {
        @Override
        public void f() {

        }
    }

    class EImpl implements E {

        @Override
        public void g() {

        }
    }

    class EGImpl implements E.G {
        @Override
        public void f() {

        }
    }

    class EImpl2 implements E {

        @Override
        public void g() {

        }

        class EG implements E.G {
            @Override
            public void f() {

            }
        }

    }
}
